<?php

/**
 * Controller_log
 * 权限管理
 */


class Controller_log extends MyApp {

	public function __construct()
	{

		parent::__construct();

		$this->model->log = YOU::loadModel('log');

	}

	/** 首页 **/
	public function actionIndex ()
	{


	}

	/** 组列表 **/
	public function actionList()
	{
		// 系统日记
		$a = $_GET['a'];
		$log_name = $this->user['user_name'];
		$this->model->log->add($a,$log_name);
		
		// 分页
		YOU::loadLib('page', "", '0');
		$tmp = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_log`");
		$count = $tmp['count'];
		$page_total = ceil($count/PAGE_LIMIT);
		// 当前页
		$p = intval($_GET['p']);
		if ($p == 0){
			$p  = 1;
		}
		if ($p > 1){
			$start = PAGE_LIMIT * ($p-1);
		}else{
			$start = 0;
		}

		$log_lists = $this->db->fetchAll("SELECT * FROM `tbl_log` ORDER BY log_id DESC LIMIT {$start}, ".PAGE_LIMIT."");

		$page = new Page(array('total' => $count, 'perpage' => PAGE_LIMIT));
		$page->next_page   = '下一页>';
		$page->pre_page    = '<上一页';
		$page->style_path  = "static/page_style";
		$this->tpl->assign("page", $page->show(4, "yahoo"));

		$this->tpl->assign("log_lists", $log_lists);
		$this->tpl->display("log/log.list.tpl.php");
	}


}



?>